<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="css/style.css">
    <link href="https://fonts.googleapis.com/css?family=Permanent+Marker" rel="stylesheet">
</head>

<body>
    <div class="signup-form">
        <form class="" action="" method="post">
            <h1>Sign Up</h1>
            <input type="text" placeholder="用户名" class="txtb" id="username">
            <input type="password" placeholder="密码" class="txtb" id="passwd">
            <input type="button" value="登录" class="signup-btn" id="btn">
            <a href="reg.html">No account yet ?</a>
        </form>
    </div>

<script src="js/jquery-3.6.0.js"></script>
<script type="text/javascript">
    $("#btn").click(function () {
        var username = $("#username").val();
        var passwd = $("#passwd").val();
        $.ajax({
            url:"/crm/login",
            type:"post",
            data:{
                username:username,
                passwd:passwd
            },
            success: function (result) {
                if(result.data == -2) {
                    alert(result.message);
                    return;
                }
                if(result.data == -1) {
                    alert(result.message);
                    return;
                }
                alert("登录成功！");
                location.href = "/emp/index.html?eid=" + result.data;
            }
        })
    })
</script>

</body>

</html>
